/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kungkhies.persistence.entities;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author clayton
 */
@Entity 
@Table(name = "activity_assessment")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "ActivityAssessment.findAll", query = "SELECT a FROM ActivityAssessment a"),
    @NamedQuery(name = "ActivityAssessment.findByKimplId", query = "SELECT a FROM ActivityAssessment a WHERE a.activityAssessmentPK.kimplId = :kimplId"),
    @NamedQuery(name = "ActivityAssessment.findByActivityId", query = "SELECT a FROM ActivityAssessment a WHERE a.activityAssessmentPK.activityId = :activityId"),
    @NamedQuery(name = "ActivityAssessment.findByAssessmentId", query = "SELECT a FROM ActivityAssessment a WHERE a.activityAssessmentPK.assessmentId = :assessmentId")
})
public class ActivityAssessment implements Serializable 
{
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ActivityAssessmentPK activityAssessmentPK;
    @JoinColumn(name = "assessment_id", referencedColumnName = "assessment_id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Assessment assessment;
    @JoinColumn(name = "activity_id", referencedColumnName = "activity_id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Activity activity;
    @JoinColumn(name = "kimpl_id", referencedColumnName = "kimpl_id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private KungkhieImpl kungkhieImpl;

    public ActivityAssessment()
    {
    }

    public ActivityAssessment(ActivityAssessmentPK activityAssessmentPK)
    {
        this.activityAssessmentPK = activityAssessmentPK;
    }

    public ActivityAssessment(long kimplId, long activityId, long assessmentId)
    {
        this.activityAssessmentPK = new ActivityAssessmentPK(kimplId, activityId, assessmentId);
    }

    public ActivityAssessmentPK getActivityAssessmentPK()
    {
        return activityAssessmentPK;
    }

    public void setActivityAssessmentPK(ActivityAssessmentPK activityAssessmentPK)
    {
        this.activityAssessmentPK = activityAssessmentPK;
    }

    public Assessment getAssessment()
    {
        return assessment;
    }

    public void setAssessment(Assessment assessment)
    {
        this.assessment = assessment;
    }

    public Activity getActivity()
    {
        return activity;
    }

    public void setActivity(Activity activity)
    {
        this.activity = activity;
    }

    public KungkhieImpl getKungkhieImpl()
    {
        return kungkhieImpl;
    }

    public void setKungkhieImpl(KungkhieImpl kungkhieImpl)
    {
        this.kungkhieImpl = kungkhieImpl;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (activityAssessmentPK != null ? activityAssessmentPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ActivityAssessment))
        {
            return false;
        }
        ActivityAssessment other = (ActivityAssessment) object;
        if ((this.activityAssessmentPK == null && other.activityAssessmentPK != null) || (this.activityAssessmentPK != null && !this.activityAssessmentPK.equals(other.activityAssessmentPK)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "com.kungkhies.persistence.entities.ActivityAssessment[ activityAssessmentPK=" + activityAssessmentPK + " ]";
    }

}
